from django.contrib import admin
from .models import Post, Comment, Like

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ('title', 'author', 'created_at', 'published_at', 'view_times', 'private', 'draft')
    list_filter = ('private', 'draft', 'author')
    search_fields = ('title', 'content')
    date_hierarchy = 'created_at'
    readonly_fields = ('view_times', 'created_at', 'last_modified_at')

@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
    list_display = ('post', 'author', 'created_at', 'is_displayed')
    list_filter = ('is_displayed', 'author')
    search_fields = ('content', 'author__username', 'post__title')
    date_hierarchy = 'created_at'

@admin.register(Like)
class LikeAdmin(admin.ModelAdmin):
    list_display = ('user', 'content_type', 'object_id', 'created_at')
    list_filter = ('content_type', 'user')
    search_fields = ('user__username',)
    date_hierarchy = 'created_at'
